package uk.ac.cloudcomputing.database;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

public class Note {
	private static final EntityManager em = EMF.get().createEntityManager();

	public static void persist(uk.ac.cloudcomputing.Note note) {
		em.getTransaction().begin();
		em.persist(note);
		em.getTransaction().commit();
	}

	public static List<uk.ac.cloudcomputing.Note> getNotes() {
		Query query = em.createQuery("select n from Note n");
		List<uk.ac.cloudcomputing.Note> dbQuery = query.getResultList();
		return new ArrayList<uk.ac.cloudcomputing.Note>(dbQuery);
	}
}
